package com.dragon.repository.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dragon.repository.entity.Site;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 位置表 Mapper 接口
 * </p>
 *
 * @author sy
 * @since 2023-08-28
 */
@Mapper
public interface SiteMapper extends BaseMapper<Site> {

    @Select("<script>" +
            "SELECT M.* FROM " +
            "(SELECT a.*,b.username AS username FROM dragon_site a " +
            "LEFT JOIN dragon_admin b on a.admin_id = b.id )M WHERE 1=1 " +
            "<if test='adminId!=null and adminId != \"\"'>"+
            " AND M.admin_id = #{adminId} " +
            "</if>"+
            "<if test='search != null and search != \"\"'> "+
            " and (M.username like CONCAT('%',#{search},'%') ) " +
            "</if> " +
            " ORDER BY M.create_time DESC "+
            "</script>")
    Page<Site> selectByName(Page<Site> sitePage, Integer adminId,String search);
}
